# include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, now, sum = 0, tmp;
    cin >> now >> n;
    if(now > 5) {
        n -= 8 - now;
        now = 1;
    }
    sum += 250 * (6 - now);
    n -= 8 - now;
    tmp = n / 7;
    n %= 7;
    sum += tmp * 1250;
    n = min(n, (long long)5);
    sum += n * 250;
    cout << sum;
}